package subumbo.micro.controller
{
	import flash.events.MouseEvent;
	
	/**
	 * Base class for any Component that gets instantiated view ListViewController
	 * 
	 * Create a class that extends from ListItemViewController and link that class to a Library Item in your fla.
	 * Use that Library Item Name to pass to the ListViewController.build method 
	 *  
	 * @author patrickwolleb
	 * 
	 */	

	public class ListItemViewController extends Component implements Listable
	{
		protected var _index:int;
		protected var _selected:Boolean;
		
		public function set data(val:Object):void
		{
			_vo = val;
			index = _vo.index;
			this.buttonMode = true;
			this.mouseChildren = false;
			this.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
		}
		
		protected function onMouseDown(e:MouseEvent):void
		{
			e.stopImmediatePropagation();
			dispatchEvent(new ApplicationEvent(ApplicationEvent.CONTROL, _vo));	
		}
		
		public function set index(val:int):void
		{
			_index = val;
		}
		
		public function get index():int
		{
			return _index;
		}
		
		public function set selected(val:Boolean):void
		{
			_selected = val;
		}
		
		public function get selected():Boolean
		{
			return _selected;
		}
	}
}